import org.openqa.selenium.By;

import java.io.IOException;

/**
 * @projectName: The-examination-questionnaire-pass-test
 * @package: PACKAGE_NAME
 * @className: HomePage
 * @author: Tongxinxin
 * @description: 首页界面功能测试
 * @date: 2025/9/22 0:29
 * @version: 1.0
 */
public class HomePage extends Util{
    public HomePage(String url) {
        super(url);
    }
    public static String url="http://8.155.1.153:8081/home";
    //未登录状态下进入首页
    public void NoLoginHome() throws IOException {
        driver.findElement(By.cssSelector("#root > div > div.content___2zk1- > div.top___1C1Zi > div.header___5xZ3f > span"));

        //判断是否返回登录页面
        String expect=driver.getTitle();

        getScreenShot(getClass().getName());
        assert expect.equals("问卷考试系统");
    }

    //检查首页中的元素
    public void HomeSuc() throws IOException, IOException {
        //进行登录
        driver.findElement(By.cssSelector("#username")).sendKeys("tong");
        driver.findElement(By.cssSelector("#password")).sendKeys("123456");
        driver.findElement(By.cssSelector("#root > div > div.content___2zk1- > div.main___x4OjT > div > form > button > span")).click();

        //检查首页标题元素
        driver.findElement(By.cssSelector("#sk-layout > div > div > section > div.ant-pro-layout-container > main > div > div.ant-page-header.ant-pro-page-container-warp-page-header.ant-pro-page-container-warp-page-header.ant-page-header-has-breadcrumb.ant-page-header-ghost > div.ant-page-header-heading > div > span"));
        //检查问卷数数量
        driver.findElement(By.cssSelector("#sk-layout > div > div > section > div.ant-pro-layout-container > main > div > div.ant-page-header.ant-pro-page-container-warp-page-header.ant-pro-page-container-warp-page-header.ant-page-header-has-breadcrumb.ant-page-header-ghost > div.ant-page-header-content > div > div > div > div > div > div.extraContent___3rMo7 > div:nth-child(1) > div > div.ant-statistic-title"));
        //检查考试数数量
        driver.findElement(By.cssSelector("#sk-layout > div > div > section > div.ant-pro-layout-container > main > div > div.ant-page-header.ant-pro-page-container-warp-page-header.ant-pro-page-container-warp-page-header.ant-page-header-has-breadcrumb.ant-page-header-ghost > div.ant-page-header-content > div > div > div > div > div > div.extraContent___3rMo7 > div:nth-child(2) > div > div.ant-statistic-title"));
        //检查我的考试按钮
        driver.findElement(By.cssSelector("#rc-tabs-0-tab-exam"));
        //检查我的问卷按钮
        driver.findElement(By.cssSelector("#rc-tabs-0-tab-survey"));
        //检查问卷记录按钮
        driver.findElement(By.cssSelector("#rc-tabs-0-tab-surveyHistory"));
        //检查考试记录按钮
        driver.findElement(By.cssSelector("#rc-tabs-0-tab-examHistory"));
        //检查创建问卷按钮
        driver.findElement(By.cssSelector("#sk-layout > div > div > section > div.ant-pro-layout-container > main > div > div.ant-pro-grid-content > div > div > div > div.ant-col.ant-col-xs-24.ant-col-sm-24.ant-col-md-24.ant-col-lg-24.ant-col-xl-8 > div > div.ant-card-body > div > a:nth-child(1)"));
        //检查创建考试按钮
        driver.findElement(By.cssSelector("#sk-layout > div > div > section > div.ant-pro-layout-container > main > div > div.ant-pro-grid-content > div > div > div > div.ant-col.ant-col-xs-24.ant-col-sm-24.ant-col-md-24.ant-col-lg-24.ant-col-xl-8 > div > div.ant-card-body > div > a:nth-child(2)"));

        //添加屏幕截图
        getScreenShot(getClass().getName());
    }
}
